<template>
  <div class="risk">
    <eagle-page-list
      ref="eaglePageList"
      @bindData="bindData"
      :queryParams="queryParams"
      url="/OtherDangerCheckTaskDetailJG/GetHiddenDangerPageData"
      :pageSize="20"
    >
      <div slot="list">
        <eagle-checkgroup
          ref="checkboxGroup"
          v-model="result"
        >
          <div
            v-for="(item, index) in list"
            :key="index"
            :border="false"
            class="mb-10"
          >
            <div class="risk_item_radio">
              <div style="width: 90%" @click="_goTaskDetail(item)">
                <div class="mb-10 hidden-danger-desc">
                  {{ index + 1 }}、{{ item.HiddenDangerDesc }}
                </div>

                <eagle-row class="dep_sort mb-10">
                  <eagle-col span="24">
                    <img
                      src="@/assets/Images/AppIcon/icon_list_type.png"
                      alt=""
                    />所属任务：{{ item.CheckTaskName }}</eagle-col
                  >
                </eagle-row>
                <eagle-row class="dep_sort mb-10">
                  <eagle-col span="24">
                    <img
                      src="@/assets/Images/AppIcon/icon_list_area.png"
                      alt=""
                    />{{ item.HiddenDangerArea }}</eagle-col
                  >
                </eagle-row>
                <eagle-row gutter="20" class="dep_sort">
                  <eagle-col span="10">
                    <img
                      src="@/assets/Images/AppIcon/icon_list_user.png"
                      alt=""
                    />{{ item.CreateChnName }}</eagle-col
                  >
                  <eagle-col span="14">
                    <img
                      src="@/assets/Images/AppIcon/icon_list_date.png"
                      alt=""
                    />{{ item.CreateDate | formatDateTime }}</eagle-col
                  >
                </eagle-row>
              </div>
              <eagle-checkbox :name="item.CTCode" :border="false" shape="round"></eagle-checkbox>
            </div>
          </div>
        </eagle-checkgroup>
      </div>
    </eagle-page-list>
    <div class="choose_btm">
      <div class="choose_cancel">
        <eagle-button class="mr-10" type="warning" size="small" @click="checkAll"
          >全选</eagle-button
        >
        <eagle-button class="mr-10" type="warning" @click="toggleAll" size="small"
          >取消全选</eagle-button
        >
        <div>已选择{{ result.length }}项</div>
      </div>
      <div class="choose_confirm">
        <eagle-button type="info" @click="submit">生成</eagle-button>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      list: [],
      result: [],
      type: this.$route.query.type,
      reportType: this.$route.query.reportType,
      queryParams: {
        dataType: "ReportTaskDetail",
      },
    };
  },
  methods: {
    bindData(data) {
      this.list = data;
    },
    checkAll() {
      this.$refs.checkboxGroup.toggleAll(true);
    },
    toggleAll() {
      this.$refs.checkboxGroup.toggleAll(false);
    },
    submit() {
      if (this.result.length > 0) {
        this.$router.push({
          name: "OtherReportdetail",
          query: {
            codes: this.result.join(","),
            type: this.type,
            reportType: this.reportType,
          },
        });
      } else {
        this.$toast.success("请先选择要生成报告的隐患");
      }
    },
    // 任务详情()
    _goTaskDetail(item) {
      this.$router.push("/OtherDanger/DangerCheckDetailView?id=" + item.ID);
    },
  },
};
</script>

<style lang="less" scoped>
.risk_item_radio {
  width: 100%;
  padding: 10px 20px;
  background-color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #e8f1f8;
}

.choose_btm {
  display: flex;
  width: 100%;
  justify-content: space-between;
  position: fixed;
  bottom: 0;
  background-color: #fff;
  .choose_cancel {
    padding: 0 10px;
    display: flex;
    align-items: center;
    float: left;
  }
  .choose_confirm {
    float: right;
    border-radius: 0;
  }
}
.hidden-danger-desc {
  font-size: 15px;
  line-height: 1.2;
}
.dep_sort_name {
  // overflow: hidden;
  // text-overflow: ellipsis;
  // white-space: nowrap;
  font-size: 14px;
}
.dep_sort {
  font-size: 12px;
  img {
    height: 15px;
    width: 15px;
    margin-right: 5px;
    vertical-align: middle;
  }
}
</style>
